package com.example.huazong.myapplication;


import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ListView;
import android.widget.TextView;

/**
 * Created by huazong on 2021/5/29.
 */

public class HideListViewActivity extends AppCompatActivity {
    ImageButton btn_back;
    Button btn_ok;
    AlertDialog alertDialog;
    AlertDialog.Builder builder_self;
    View selfView;
    ListView hide_list;
    TextView txt1;
    String[] menu={"账号管理","手机号码                    123******90","账号安全","消息通知","隐私","通用",
    "辅助功能","关于本软件的一些申明"};
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.hide_list_view);
        hide_list=(ListView)findViewById(R.id.hide_list);
        btn_back=(ImageButton)findViewById(R.id.btn_back);



        btn_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent=new Intent(HideListViewActivity.this, ThirdActivity.class);
                startActivity(intent);
            }
        });

        ArrayAdapter<String> madpter=new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,menu);
        hide_list.setAdapter(madpter);
        hide_list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                if (position==7){
                    //这里使用自定义消息对话框
                    DiyAlertDialog();
                }
            }
        });




    }

    private void DiyAlertDialog() {
//        组合自定义对话框
        btn_ok = (Button) findViewById(R.id.btn_ok);
        builder_self = new AlertDialog.Builder(this);
        builder_self.setTitle("用户须知");
        builder_self.setIcon(R.drawable.icon7);
        builder_self.create();//组装完毕

        //获取页面和组件
        selfView = View.inflate(HideListViewActivity.this, R.layout.diy_introdution_list, null);
        txt1 = (TextView) selfView.findViewById(R.id.txt1);
        builder_self.setView(selfView);
        alertDialog = builder_self.show();
    }
    public void btn_ok(View view){
                alertDialog.cancel();
    }

}

